﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace EC21_EDiamond
{
    public partial class MasterAdmin : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
                {
                    HttpCookie myCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
                    myCookie.Expires = DateTime.Now.AddDays(-1d);
                    Response.Cookies.Add(myCookie);
                    HttpContext.Current.Session.Remove("admin");
                    HttpContext.Current.Session.Abandon();
                }
            }
            else
            {
                lblAdmin.Text = Session["admin"].ToString();
            }
        }

        protected void logOut_Click(object sender, EventArgs e)
        {
            Session["admin"] = null;
            Roles.DeleteCookie();
            Response.Redirect("~/admin/LoginAdmin.aspx");
        }
    }
}